package t_973

import (
	"math"
	"sort"
)

func kClosest(points [][]int, K int) [][]int {
	sort.Slice(points, func(i, j int) bool {
		array1, array2 := points[i], points[j]
		return pow2(array1[0], array1[1]) < pow2(array2[0], array2[1])
	})

	return points[:K]
}
func pow2(i, j int) float64 {

	return math.Pow(float64(i), 2) + math.Pow(float64(j), 2)
}
